mineralprocessor = {}

local ESTEMOD = minetest.get_current_modname()

local S = minetest.get_translator(ESTEMOD)
local util = dofile(minetest.get_modpath(ESTEMOD) .. "/util.lua")
-- dofile(minetest.get_modpath(ESTEMOD) .. "/util.lua")
-- dofile(minetest.get_modpath(ESTEMOD) .. "/util.lua")

minetest.register_node("mineralprocessor:processor", {
    -- INFO
    description = S("Processor"),
    -- DRAW NODE
	drawtype = "nodebox",
    groups = {cracky=2},
    tiles = {
        "processor_top.png",    -- TOP
        "default_cobble.png",  -- BOT
        "default_cobble.png",  -- LEFT
        "default_cobble.png",  -- RIGHT
        "default_cobble.png",  -- FRONT
        "default_cobble.png",  -- BACK
    },
    node_box = {
        type = "fixed",
        fixed = {
            {-0.3750, -0.4375, -0.4375,  0.3750,  0.5000, -0.3125}, --Wände N
            {-0.4375, -0.4375, -0.3750, -0.3125,  0.5000,  0.3750}, --Wände O
            { 0.3750, -0.4375,  0.4375, -0.3750,  0.5000,  0.3125}, --Wände S
            { 0.4375, -0.4375,  0.3750,  0.3125,  0.5000, -0.3750}, --Wände W
            {-0.3750, -0.5000, -0.3750,  0.3750,  0.3750,  0.3750}, --Boden
        },
    },
    selection_box = {
        type = "fixed",
        fixed = {
            -- {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- ganze Block
            {-0.3750, -0.4375, -0.4375,  0.3750,  0.5000, -0.3125}, --Wände N
            {-0.4375, -0.4375, -0.3750, -0.3125,  0.5000,  0.3750}, --Wände O
            { 0.3750, -0.4375,  0.4375, -0.3750,  0.5000,  0.3125}, --Wände S
            { 0.4375, -0.4375,  0.3750,  0.3125,  0.5000, -0.3750}, --Wände W
            {-0.3750, -0.5000, -0.3750,  0.3750,  0.5000,  0.3750}, --Boden
        },
    },

    -- CALLBACKS DE ACCION DIRECTA
    on_construct = function (pos)
        local meta = minetest.get_meta(pos)
		local inv = meta:get_inventory()
        meta:set_string("infotext", "Procesador detenido")
		inv:set_size('src', 2)
		inv:set_size('comp', 1)
		inv:set_size('dst', 4)
		processor_updater(pos, 0) -- que llama a la definición del formspec
    end,
    on_punch = function(pos, node, puncher, pointed_thing) 
        -- doconversion("Tal")
    end,
    on_rightclick = function(pos, node, puncher, pointed_thing) 
        -- doconversion("Pascual")
    end,
    -- INDEPENDIENTES ON TIMER
    on_timer = processor_updater,
    -- --------------------------------------
    -- Cualquier accion sobre el inventario del nodo activa el timer
    -- el parametro que toma start es el delay con el que se invoca la funcion.
    on_metadata_inventory_move = function(pos)
        minetest.chat_send_player("singleplayer", "INVENTORY_MOVE")
		minetest.get_node_timer(pos):start(10.0)
	end,
	on_metadata_inventory_put = function(pos)
		-- start timer function, it will sort out whether furnace can burn or not.
        minetest.chat_send_player("singleplayer", "INVENTORY_PUT")
		minetest.get_node_timer(pos):start(10.0)
	end,
	on_metadata_inventory_take = function(pos)
		-- check whether the furnace is empty or not.
        minetest.chat_send_player("singleplayer", "INVENTORY_TAKE")
		minetest.get_node_timer(pos):start(10.0)
	end
    -- --------------------------------------

    -- allow_metadata_inventory_put = allow_metadata_inventory_put,
	-- allow_metadata_inventory_move = allow_metadata_inventory_move,
	-- allow_metadata_inventory_take = allow_metadata_inventory_take,

})


--[[


-- Registro de un contador (este no se si cuenta que es para el crecimiento de la hierba)
minetest.register_abm({
    nodenames = {"default:dirt_with_grass"},
    neighbors = {"default:water_source", "default:water_flowing"},
    interval = 10.0, -- Run every 10 seconds
    chance = 50, -- Select every 1 in 50 nodes
    action = function(pos, node, active_object_count, active_object_count_wider)
        minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "aliens:grass"})
    end
})


]]--